1 using UnityEngine;
2 using
System.Collections;
3
4 public
class SlerpToTarget : MonoBehaviour {
5
6     
public GameObject target;
7     
public float speed;
8
9     
// Use this for initialization
10     
void Start () {
11         
12     }
13     
14     
// Update is called once per frame
15     
void Update () {
16     
17     }
18
19     
void FixedUpdate()
20     {
21         Quaternion componentRotation = target.transform.rotation;
22         componentRotation.eulerAngles =
new Vector3 (transform.rotation.x, componentRotation.eulerAngles.y, transform.rotation.z);
23
24         transform.rotation = Quaternion.Slerp (
25             transform.rotation,
26             componentRotation,
27             Time.fixedDeltaTime * speed
28         );
29     }
30 }


Gõ tìm kiếm nhanh...